//要使用,必须引用prototype.js
function online()
{
	
	var url='../json/online';
	var params="";
	var myAjax=new Ajax.Request(
    url,
    {
    	method:'post',
		parameters:params,
		onComplete: processResponse1,
		asynchronous:true
    	
    });

}
function processResponse1(request)
{
	var res = request.responseText.evalJSON();
	var online=res['result']['online'];
	//var username=document.cookie;
	var username=getCookie("userName");
	var useid=getCookie("userId");
	if(username==null)
		{
		window.location.href="../index.html";
		}
	else
		{
	    document.getElementById("onp").innerHTML='当前在线人数：'+online+'人';
	    document.getElementById("demo").innerHTML='Welcome '+username+'!';
	    //var my=CurentTime();
	    
	    
	   // alert(my);
		}
} 
function setCookie(name,value)
{
	var exp = new Date();
	exp.setTime(exp.getTime() + 2*60*1000);
	document.cookie = name + "="+ escape(value) + ";expires=" + exp.toGMTString();
}
function getCookie(name)
{
	var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
	if(arr=document.cookie.match(reg))
		return (arr[2]);
	else
		return null;
}
function delCookie(name)
{
	var exp = new Date();
	exp.setTime(exp.getTime() - 1);
	var cval=getCookie(name);
	if(cval!=null)
		document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
function getsec(str){
	var str1=str.substring(1,str.length)*1;
	var str2=str.substring(0,1);
	if (str2=="s") 
		return str1*1000;
	else if (str2=="h")
		return str1*60*60*1000;
	else if (str2=="d")
	return str1*24*60*60*1000;
}

function getActionTitle()
{
	var mydata=CurentTime();
	var url='../json/displayActionTitle';
	var params="title=&id=&topCheckDate=&bottomCheckDate=&topEndDate=&bottomEndDate=&topStartDate="+mydata+"&bottomStartDate=2013-08-17 00:00:00&max="+10+"&first="+1;
	var myAjax=new Ajax.Request(
    url,
    {
    	method:'post',
		parameters:params,
		onComplete: processResponseActionTitle,
		asynchronous:true
    	
    });
}
function processResponseActionTitle(request)
{
	 var res = request.responseText.evalJSON();
	 var title=res['result']['flag'];
	 alert(title);
	 document.getElementById("inform").innerHTML=title;
	
}
function CurentTime()
{ 
    var now = new Date();
   
    var year = now.getFullYear();       //年
    var month = now.getMonth() + 1;     //月
    var day = now.getDate();            //日
   
    var hh = now.getHours();            //时
    var mm = now.getMinutes();          //分
    var ss = now.getSeconds();          //miao
    
   
    var clock = year + "-";
   
    if(month < 10)
        clock += "0";
   
    clock += month + "-";
   
    if(day < 10)
        clock += "0";
       
    clock += day + " ";
   
    if(hh < 10)
        clock += "0";
       
    clock += hh + ":";
    
  
    
    if (mm < 10) clock += '0'; 
    clock += mm+ ":";
    if(ss < 10)
        clock += "0";
       
    clock += ss;
    return(clock); 
} 


